Conditional Statements and Loops in C Language

IMPORTANT

Conditional Statements and Loops in C Language: Overview

This topic covers concepts, such as Conditional Statements in C/C++, Loops and Iteration, If-else in C/C++, If statement in C/C++, For Loop, Syntax of For Loop, Test Expression in For Loop, Syntax of While Loop, Nested-if in C/C++, While Loop, etc.

Important Questions on Conditional Statements and Loops in C Language

MEDIUM
IMPORTANT

What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
    int n = 15;
    for (; ;) 
    cout << n;
    return 0;
}

EASY
IMPORTANT

 If you have to make decision based on multiple choices, which of the following is best suited?

EASY
IMPORTANT

Identify the updated expression in the given for loop

for(int i = 0; i < n; i++){
}

MEDIUM
IMPORTANT

What is the output of the following code:
void main()
{
int i;
for(i=65;i<70;i++)
 printf(“%c,”,i);
}
 

MEDIUM
IMPORTANT

int main()
{
    int i=0;
     
    for (i = 1; i <= 10; i++)
    {
        printf( "Hello World\n");   
    }
 
    return 0;
}

Identify the test condition and how mony times the for loop will execute?

MEDIUM
IMPORTANT

for(int i = 0; i < n; i++){

print(i);
}

Identify the initialisation expression in for loop.

MEDIUM
IMPORTANT

What is the output of the following code:
void main()
{
int 5;
for(i=5;i<=15;i++)
 printf(“%d\n”,i);
}
 

MEDIUM
IMPORTANT

Syntax of If-else-if ladder in C/C++ is__________

MEDIUM
IMPORTANT

What will be the output of the following C code?

#include <stdio.h>

int main(){
    int a = 11;
    
    while (a < 20) {
        printf("%d  ", a);
        a += 2;
    }
    
    return 0;
}

EASY
IMPORTANT

Nested if…else statement can be replaced by the statement of ___

MEDIUM
IMPORTANT

 Which of the following is valid syntax for creating a while loop?

MEDIUM
IMPORTANT

Find the output of the given C program.

#include<stdio.h>
int main()
{
  if(-5)
  printf("a");
  printf("b");
  else
  printf("c");
  printf("d");
  return 0;
}

HARD
IMPORTANT

 What is the output of the C Program.?

int main()
{
    if( 4 > 5 )
    {
        printf("Hurray..\n");
    }
     printf("Yes");

    return 0;

}

EASY
IMPORTANT

Which loop is faster in C++ Language, for, while or do-while?

MEDIUM
IMPORTANT

 What will be the output of the following C++ code?

#include <iostream>
using namespace std;
int main() {

    if (0) {
        cout << "Hello" ;
    }
    else 
    {
        cout << "Good Bye" ;
    }
    return 0;
}

EASY
IMPORTANT

Decision Control statements in C++ can be implemented using